#coding=utf8
#_author_: chanceyang
#date:2019/11/27
from base.server_auto_start import Server
import threading
from util.configer_generator import configer

class Mult_start:
    def __init__(self):
        self.device_list=Server.find_Devices()
        self.thread_list=[]
        self.driver_args_lsit={}#启动driver所需要的参数udid:p_port

    def thread_List(self):
        self.server = Server(configer.get_str("appium", "server_process_name"))
        device_list=list(self.server.device_port_dic.keys())
        for i in device_list:
            temp_list=self.server.device_port_dic[i]
            self.driver_args_lsit[i]=temp_list[0]
            temp_list.append(i)
            th=threading.Thread(target=self.server.start_Server,args=(*temp_list,))#temp_list[0],temp_list[1],temp_list[2]
            self.thread_list.append(th)

    def start_servers_threads(self):
        self.thread_List()
        if self.thread_list!=None:
            for i in self.thread_list:
                i.start()



if __name__=="__main__":
    ms=Mult_start()
    ms.start_servers_threads()
    print(ms.driver_args_lsit)







